﻿using AutoMapper;
using HamcoWcs.Contract.ContractCommon;
using HamcoWcs.Contract.ContractMes;
using HamcoWcs.DAL;
using HamcoWcs.Models.Common;
using HamcoWcs.Service.Mes;
using Quartz;
using System.Threading.Tasks;

namespace HamcoWcs.Workers
{
    /// <summary>定时获取生产设置的计划</summary>
    [DisallowConcurrentExecution]
    public class GetStockerPlanWorker : WorkerBase
    {
        private readonly IMesCommunicateService _mesCommunicateService;
        public GetStockerPlanWorker(IMesCommunicateService mesCommunicateService, WcsDbContext wcsDbContext, IMapper mapper, ILoggerService logger) : base(wcsDbContext, mapper, logger)
        {
            _mesCommunicateService = mesCommunicateService;
        }

        public override Task Execute(IJobExecutionContext context)
        {
            // MES在线时请求计划数
            if (GlobalValue.MesOnlineFlag)
            {
                _mesCommunicateService.CurrentStockerEmptyBoxPlanRequest("CJSTW100");
                _mesCommunicateService.CurrentStockerEmptyBoxPlanRequest("CJSTW200");
            }

            return Task.CompletedTask;
        }
    }
}
